#pragma once

#include "D3DUtils.h"

class D3DApp
{
public:
	D3DApp();
	D3DApp(HINSTANCE hInstance, std::string winCaption
		, D3DDEVTYPE devType, DWORD requestedVP);
	virtual ~D3DApp();

	HWND GetMainWindow() { return mhMainWindow; }
	HINSTANCE GetAppInstance() { return mhAppInstance; }
	bool GetDeviceLost();

	virtual LRESULT MsgProc(UINT msg, WPARAM wParam, LPARAM lParam);
	virtual int Run();

protected:
	virtual void InitMainWindow();
	virtual void InitDirect3D();

	virtual bool CheckDeviceCaps()	{ return true; }
	virtual void OnLostDevice()		{}
	virtual void OnResetDevice()	{}
	virtual void Update(float dt)	{}
	virtual void Draw()				{}

	void EnableFullscreen();

	HWND mhMainWindow;
	HINSTANCE mhAppInstance;
	std::string mMainWindowCaption;

	IDirect3D9* mD3DObject;
	D3DPRESENT_PARAMETERS mD3Dpp;
	D3DDEVTYPE mDevType;
	DWORD mRequestedVP;

	bool mAppPaused;

private:
	void ResetDevice();
};


